package com.songlanyun.modules.pointsexchangeconfig.controller.admin;

import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.R;
import com.songlanyun.common.validator.ValidatorUtils;
import com.songlanyun.modules.pointsexchangeconfig.entity.PointsExchangeConfigEntity;
import com.songlanyun.modules.pointsexchangeconfig.service.PointsExchangeConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;


/**
 * 积分兑换配置
 *
 * @author wuchao
 * @email songlanyun@gmail.com
 * @date 2022-08-06 15:34:36
 */
@RestController
@RequestMapping("/admin/points/exchange/config")
public class PointsExchangeConfigAdminController {
    @Autowired
    private PointsExchangeConfigService pointsExchangeConfigService;

    /**
     * 信息
     */
    @GetMapping("/info")
    //@RequiresPermissions(":pointsexchangeconfig:info")
    public R info() {
        PointsExchangeConfigEntity pointsExchangeConfig = pointsExchangeConfigService.loadConfig(false);

        return R.ok().put("data", pointsExchangeConfig);
    }

    /**
     * 保存
     */
    @PostMapping("/add")
    //@RequiresPermissions(":pointsexchangeconfig:save")
    public R add(@RequestBody PointsExchangeConfigEntity pointsExchangeConfig) {
        ValidatorUtils.validateEntity(pointsExchangeConfig);
        pointsExchangeConfigService.add(pointsExchangeConfig);

        return R.ok();
    }


}
